<?php 
	session_start();
	include('include/db_connect.php');
	include("include/header.php");
	include("include/menu.php"); 
?>		
<!-- Start of Main Content Area -->
<div id="main_content">
	<!-- Start of New Item Description -->
	<div id="new_item">
		<div id="currentFilms">
			<div id="wrapper">
				<div>
					<div id="slideshow">
						<ul id="slides">
						<?php
						$selectaanbieding = "SELECT idPRODUCT FROM  `PRODUCT` WHERE korting >0 ORDER BY korting DESC LIMIT 1";				
						$selectresult = mysql_query($selectaanbieding) or die(mysql_error());
						$selectres = mysql_fetch_assoc($selectresult);
						$idProduct = $selectres['idPRODUCT'];
							echo '<li><a href="productdetail.php?id='.$idProduct.'"><img src="images/reclame-nieuw2.jpg" alt="Top aanbieding"></a></li>';
							echo '<li><a href="overons.php"><img src="images/reclame-nieuw.jpg" alt="Over Best PC"></a></li>';
							echo '<li><a href="register.php"><img src="images/reclame-nieuw3.jpg" alt="Test"></a></li>';
						?>
						</ul>
					</div>
				</div>
			</div>
			<script type="text/javascript">
				var slideshow=new TINY.fader.fade('slideshow',{
					id:'slides',
					auto:6,
					resume:true,
					activeclass:'current',
					visible:true,
					position:0
				});
			</script>
		</div>
	</div>
	<!-- End of New Item Description -->
	<div class="h_divider">&nbsp;</div>
		<!-- Start of Sub Item Descriptions -->
		<div class="sub_items">
		<!-- Start Left Sub Item -->
			<div class="sub_left">
				<?php 
				$selectaanbieding = "SELECT * FROM  `PRODUCT` WHERE korting >0 ORDER BY korting DESC LIMIT 0,1";				
				$selectresult = mysql_query($selectaanbieding) or die(mysql_error());
				$selectres = mysql_fetch_assoc($selectresult);
				$aanbiedingID= $selectres['idPRODUCT'];
				$aanbiedingNaam= $selectres['naam'];
				$aanbiedingPrijs= $selectres['prijs'];
				$aanbiedingOmschrijving= $selectres['omschrijving'];
				$aanbiedingImg= $selectres['bestandsnaam'];
				$aanbiedingKorting= $selectres['korting'];
				
				
				$aanbiedingNaam = substr($aanbiedingNaam,0,40);
				$aanbiedingOmschrijving= substr($aanbiedingOmschrijving, 0, 100)." ...";
				$Nieuweprijs = ($aanbiedingPrijs * ((100-$aanbiedingKorting)/100));
				$Nieuweprijs = number_format($Nieuweprijs, 2, ',', ' ');
				#echo $;
				echo '<div class="sub_items_text">';
				echo '<div class="sub_items">';
				echo '<div class="sub_left">';
				echo '<div class="sub_items_header">';
				echo '<h2><strong><a href="productdetail.php?id='.$aanbiedingID.'">'.$aanbiedingNaam.'</a></strong></h2>';
				echo '<h2></h2>';
				echo '</div>';
				echo '<div class="sub_items_image">';
					echo '<a href="productdetail.php?id='.$aanbiedingID.'"><img src="images/producten/normal/normal_'.$aanbiedingImg.'" width="167" height="164" alt="Sub Item Name"></a>';				echo '</div>';
				echo '<div class="sub_items_text">';
				
				echo '<p><strong>'.$aanbiedingOmschrijving.'</strong></p>';

				echo'</div>';
				echo'<div class="sub_items_cartinfo">';
				echo'<div class="price">';
				$aanbiedingPrijs= number_format($aanbiedingPrijs, 2, ',', ' ');
				if($aanbiedingKorting>0){
					echo'<h2> <strike>Oude prijs: &euro; '.$aanbiedingPrijs.'</strike></h2>';
					echo'<h2> Nieuwe prijs: &euro; '.$Nieuweprijs.'</h2>';
				}
				else{
					echo'<h2> Prijs: &euro; '.$aanbiedingPrijs.'</h2>';
				}
				echo'</div>';
				echo'<div class="addtocart">';
				echo'<a href="winkelwagen.php?id='.$aanbiedingID.'&action=add"><img src="images/shopping_cart.jpg" width ="38px" title="Leg product in wagen" alt="Leg product in wagen"></a>';
				echo'</div>';
				echo'<div class="clearthis">&nbsp;</div>';
			echo'</div>';
			echo'<div class="clearthis">&nbsp;</div>';
			echo'</div>';
			echo'<div class="sub_right">';
			$selectaanbieding = "SELECT * FROM  `PRODUCT` WHERE korting >0 ORDER BY korting DESC LIMIT 1,1";				
				$selectresult = mysql_query($selectaanbieding) or die(mysql_error());
				$selectres = mysql_fetch_assoc($selectresult);
				$aanbiedingID= $selectres['idPRODUCT'];
				$aanbiedingNaam= $selectres['naam'];
				$aanbiedingPrijs= $selectres['prijs'];
				$aanbiedingOmschrijving= $selectres['omschrijving'];
				$aanbiedingImg= $selectres['bestandsnaam'];
				$aanbiedingKorting= $selectres['korting'];
				
				
				$aanbiedingNaam = substr($aanbiedingNaam,0,40);
				$aanbiedingOmschrijving= substr($aanbiedingOmschrijving, 0, 100)." ...";
				$Nieuweprijs = ($aanbiedingPrijs * ((100-$aanbiedingKorting)/100));
				$Nieuweprijs = number_format($Nieuweprijs, 2, ',', ' ');

				echo '<div class="sub_items_header">';
					echo '<h2><strong><a href="productdetail.php?id='.$aanbiedingID.'">'.$aanbiedingNaam.'</a></strong></h2>';
					echo '<h2></h2>';
				echo '</div>';
				echo '<div class="sub_items_image">';
						echo '<a href="productdetail.php?id='.$aanbiedingID.'"><img src="images/producten/normal/normal_'.$aanbiedingImg.'" width="167" height="164" alt="Sub Item Name"></a>';
				echo '</div>';
				echo '<div class="sub_items_text">';
					echo '<p><strong>'.$aanbiedingOmschrijving.'</strong></p>';
				echo'</div>';
				echo'<div class="sub_items_cartinfo">';
					echo'<div class="price">';
					$aanbiedingPrijs= number_format($aanbiedingPrijs, 2, ',', ' ');
					if($aanbiedingKorting>0){
					echo'<h2> <strike>Oude prijs: &euro; '.$aanbiedingPrijs.'</strike></h2>';
					echo'<h2> Nieuwe prijs: &euro; '.$Nieuweprijs.'</h2>';
					}
					else{
					echo'<h2> Prijs: &euro; '.$aanbiedingPrijs.'</h2>';
					}
				echo'</div>';
				echo'<div class="addtocart">';
					echo'<a href="winkelwagen.php?id='.$aanbiedingID.'&action=add"><img src="images/shopping_cart.jpg" width ="38px" title="Leg product in wagen" alt="Leg product in wagen"></a>';
				echo'</div>';
					echo '<div class="clearthis">&nbsp;</div>';
				echo '</div>';
				echo '<div class="clearthis">&nbsp;</div>';
			echo '</div>'; 
		echo '<!-- End of Right Sub Item -->';
		echo '<div class="clearthis">&nbsp;</div>';
	echo '</div>';
	echo '<!-- End of Sub Item Descriptions -->';
				$selectaanbieding = "SELECT * FROM  `PRODUCT` WHERE korting >0 ORDER BY korting DESC LIMIT 2,1";				
				$selectresult = mysql_query($selectaanbieding) or die(mysql_error());
				$selectres = mysql_fetch_assoc($selectresult);
				$aanbiedingID= $selectres['idPRODUCT'];
				$aanbiedingNaam= $selectres['naam'];
				$aanbiedingPrijs= $selectres['prijs'];
				$aanbiedingOmschrijving= $selectres['omschrijving'];
				$aanbiedingImg= $selectres['bestandsnaam'];
				$aanbiedingKorting= $selectres['korting'];
				
				
				$aanbiedingNaam = substr($aanbiedingNaam,0,40);
				$aanbiedingOmschrijving= substr($aanbiedingOmschrijving, 0, 100)." ...";
				$Nieuweprijs = ($aanbiedingPrijs * ((100-$aanbiedingKorting)/100));
				$Nieuweprijs = number_format($Nieuweprijs, 2, ',', ' ');
				#echo $;
				echo '<div class="sub_items_text">';
				echo '<div class="sub_items">';
				echo '<div class="sub_left">';
				echo '<div class="sub_items_header">';
				echo '<h2><strong><a href="productdetail.php?id='.$aanbiedingID.'">'.$aanbiedingNaam.'</a></strong></h2>';
				echo '<h2></h2>';
				echo '</div>';
				echo '<div class="sub_items_image">';
					echo '<a href="productdetail.php?id='.$aanbiedingID.'"><img src="images/producten/normal/normal_'.$aanbiedingImg.'" width="167" height="164" alt="Sub Item Name"></a>';
				echo '</div>';
				
				echo '<div class="sub_items_text">';
				
				echo '<p><strong>'.$aanbiedingOmschrijving.'</strong></p>';

				echo'</div>';
				echo'<div class="sub_items_cartinfo">';
					echo'<div class="price">';
					$aanbiedingPrijs= number_format($aanbiedingPrijs, 2, ',', ' ');
					if($aanbiedingKorting>0){
					echo'<h2> <strike>Oude prijs: &euro; '.$aanbiedingPrijs.'</strike></h2>';
					echo'<h2> Nieuwe prijs: &euro; '.$Nieuweprijs.'</h2>';
					}
					else{
					echo'<h2> Prijs: &euro; '.$aanbiedingPrijs.'</h2>';
					}
				echo'</div>';
				echo'<div class="addtocart">';
				
					echo'<a href="winkelwagen.php?id='.$aanbiedingID.'&action=add"><img src="images/shopping_cart.jpg" width ="38px" title="Leg product in wagen" alt="Leg product in wagen"></a>';
				echo'</div>';
				echo'<div class="clearthis">&nbsp;</div>';
			echo'</div>';
			echo'<div class="clearthis">&nbsp;</div>';
			echo'</div>';
			
			echo'<div class="sub_right">';
			$selectaanbieding = "SELECT * FROM  `PRODUCT` WHERE korting >0 ORDER BY korting DESC LIMIT 3,1";				
				$selectresult = mysql_query($selectaanbieding) or die(mysql_error());
				$selectres = mysql_fetch_assoc($selectresult);
				$aanbiedingID= $selectres['idPRODUCT'];
				$aanbiedingNaam= $selectres['naam'];
				$aanbiedingPrijs= $selectres['prijs'];
				$aanbiedingOmschrijving= $selectres['omschrijving'];
				$aanbiedingImg= $selectres['bestandsnaam'];
				$aanbiedingKorting= $selectres['korting'];
				
				
				$aanbiedingNaam = substr($aanbiedingNaam,0,40);
				$aanbiedingOmschrijving= substr($aanbiedingOmschrijving, 0, 100)." ...";
				$Nieuweprijs = ($aanbiedingPrijs * ((100-$aanbiedingKorting)/100));
				$Nieuweprijs = number_format($Nieuweprijs, 2, ',', ' ');

				echo '<div class="sub_items_header">';
					echo '<h2><strong><a href="productdetail.php?id='.$aanbiedingID.'">'.$aanbiedingNaam.'</a></strong></h2>';
					echo '<h2></h2>';
				echo '</div>';
				echo '<div class="sub_items_image">';
						echo '<a href="productdetail.php?id='.$aanbiedingID.'"><img src="images/producten/normal/normal_'.$aanbiedingImg.'" width="167" height="164" alt="Sub Item Name"></a>';
				echo '</div>';
				echo '<div class="sub_items_text">';
					echo '<p><strong>'.$aanbiedingOmschrijving.'</strong></p>';
				echo'</div>';
				echo'<div class="sub_items_cartinfo">';
					echo'<div class="price">';
					$aanbiedingPrijs= number_format($aanbiedingPrijs, 2, ',', ' ');
					if($aanbiedingKorting>0){
					echo'<h2> <strike>Oude prijs: &euro; '.$aanbiedingPrijs.'</strike></h2>';
					echo'<h2> Nieuwe prijs: &euro; '.$Nieuweprijs.'</h2>';
					}
					else{
					echo'<h2> Prijs: &euro; '.$aanbiedingPrijs.'</h2>';
					}
				echo'</div>';
				echo'<div class="addtocart">';
					echo'<a href="winkelwagen.php?id='.$aanbiedingID.'&action=add"><img src="images/shopping_cart.jpg" width ="38px" title="Leg product in wagen" alt="Leg product in wagen"></a>';
				echo'</div>';

				echo'<div class="clearthis">&nbsp;</div>';
			echo'</div>';
			echo'<div class="clearthis">&nbsp;</div>';
		echo'</div>';
		echo'<div class="clearthis">&nbsp;</div>';
	echo '</div>';
	echo '<div class="clearthis">&nbsp;</div>';	
	echo '</div>';		
	echo '<div class="clearthis">&nbsp;</div>';	
	echo '</div>';		
echo '</div>';		
				
				?>

<!-- End of Main Content Area -->
<div class="clearthis">&nbsp;</div>
<?php include("include/footer.php"); ?>